package ru.ifmo.ctd.year2008.notepad.diff;

import ru.ifmo.ctd.year2008.notepad.Text;

import java.io.Serializable;
import java.util.List;

public class DiffSet implements Serializable {
	private static final long serialVersionUID = 2181414243443402240L;
	
	private final List<Diff> diffList;

    public DiffSet(List<Diff> diffList) {
        this.diffList = diffList;
    }

    public Text apply(Text text) {
        for (Diff diff: diffList) {
            text = diff.apply(text);
            if (text == null) {
                return null;
            }
        }
        return text;
    }

    public int size() {
        return diffList.size();
    }

    @Override
    public String toString() {
        return "DiffSet{" +
                "diffList=" + diffList +
                '}';
    }
}
